Massive debugging session. Still lots of bugs though