Refactored the compilation units.

WARNING: while browsing around some problems have been found. Please
look for "FIXME" and "TODO"s across the code.