Fixed a few flaws and cmake files