on and emit working, primitive memory leak detection added
using scan-build for leak detection instead