Fixed CMake build.
fixed some build errors
Initial port to Linux. (Some cleanup) missing