Changed documentation and cleaned up code