Documentation and cleaning

All code has been commented and unused code has been removed.