Lagrangian to Hamiltonian

I'm having some problems with an assignment where I have to state the Hamiltonian from the kinetic energy $T$ and potential energy $U$. These are as follows:

$$T(\dot{x},\dot{y})=2m\dot{x}^{2}+\frac{1}{2}m\dot{y}^{2}-m\dot{x}\dot{y}$$ and $$U(x,y)=-mgy+\frac{1}{2}k(y-l_{0})^{2}+U_{0},$$ where $m$, $g$, $k$, $l_{0}$ and $U_{0}$ are constants.

Now, I have to derive the generalised momenta $p_{x}$ and $p_{y}$, which I do with the equation:

$$p_{x}=\frac{\partial T}{\partial \dot{x}}$$ and $$p_{y}=\frac{\partial T}{\partial \dot{y}},$$ and I'm using only $T$ since the potential $U$ does not depend on the generalized coordinates.

This is pretty straightforward, and I end out with $\dot{x}$ and $\dot{y}$ given by the momenta as: $$\dot{x}=\frac{p_{x}+p_{y}}{4m}$$ and $$\dot{y}=\frac{p_{x}+p_{y}}{m}$$ Now the Hamiltonian should be simple to get, since I only have to insert these into the equation for the kinetic energy. But, according to the solution, I have to show that the Hamiltonian is given by: $$H(x,y,p_{x},p_{y}) = \frac{1}{6m}(p_{x}^{2}+2p_{x}p_{y}+4p_{y}^{2}) + U$$ But if I do what I said above I instead get: $$H(x,y,p_{x},p_{y}) = \frac{3}{8m}(p_{x}^{2}+2p_{x}p_{y}+p_{y}^{2}) + U$$ And I really can't figure out where I'm doing it wrong. Is my way to go not the correct ? Expressing $\dot{x}$ and $\dot{y}$ with respect to the momenta, and then just inserting it in the kinetic energy ?

Don't think the solution is wrong, but you never know. So yeah, I need some help to get moving :)

-
I think the velocities dependent of momentums are wrong by your calculation. In addition, the hamiltonian is a function of coordinate and momentum, not the coordinate and its derivative. –  qfzklm Mar 20 at 17:39
Ahhh, yes, typo in the Hamiltonian. But why is $m\dot{x} \neq p_{x}$ ? Isn't that the definition of momentum ? –  Denver Dang Mar 20 at 17:46
You've defined the momentum $p_x=\partial T/\partial\dot{x}$, no? –  Kyle Kanos Mar 20 at 18:03
Hmmm, I can see that that doesn't make much sense no :/ But that seems to make it difficult to get rid of the $\dot{x}$ and $\dot{y}$, or am I missing something ? –  Denver Dang Mar 20 at 18:10
I haven't tried it, but I imagine a little bit of algebra will go a long way. –  Kyle Kanos Mar 20 at 18:21

Well, you better check your "pretty straightforward" calculation again, as $$\dot{x}\neq\frac{p_{x}+p_{y}}{4m}$$ and $$\dot{y}\neq\frac{p_{x}+p_{y}}{m}.$$

-