Minor cleanup
Fix some memory issues