fixed a bucnh of bugs, did some more TODO things