Refactoring of code and cmake system.
Fix compile warnings.