Fixed loads of bugs

Now in the develop branch!