Fixed a lot of bugs, finally works!