Finished all code

Some bugfixes, but its pretty much done.