Code cleaning. Code documentation for doxygen. Some code refactoring.