Bug fixes
Implemented most of the missing stuff and fixed lots of bugs.