Added documentation, removed useless comments, fixed compile error