Updated documentation and cleaned up code