Fixed various bugs which were causing memory leaks and crashes
Trimmed compiler flags in CMakeLists.txt