Updated documentation and cleaned some code