Added all javadocs and cleaned up code as I went along