cleanup memory ptr frees

- add delete allocated ptr
- use __delete() to free allocated memory

*Please do not merge before #267*