Add sanitize options to CMakeLists.txt
Fix some memory errors