Clean up references properly
Merge pull request #38 from jimbraun/0033-memory-error-in-pybindings

Clean up references properly