Code review

Changed a few things including :
* Stylistic changes
* Added some documentation
* Some code review, including at least one possible bug, still have to
  investigate.