Fixed all kinds of stuff and setup a bunch of tests (that are all passing\!\!\!).