Fixes #59

Deletes all pointers before recreating objects to prevent memory leaks.