Fix some things for linux
Use the right delete
Fix some memory leaks