Feature/resource cleanup

This PR fixes #18.