Modernize source code and cmake file