Minor fixes for memory leak

Signed-off-by: Hin Lam <max21226@Hin-Lams-iMac.local>
Merge remote-tracking branch 'max21226/memoryLeak' into rotato_master