Documentation

Documented and cleaned up a lot of code; The code is now send-inable;