More code cleanup
This MR continues the work in !34 (merged) and cleans up core classes, adds documentation and splits implementation and declaration into different files.
The documentation should be doxygen-compatible (make reference
produces the HTML version)