Closes #190 - Fix all potential resource leaks