Clean up file handles
Merge pull request #125 from cikl/cleanup_handles

Clean up file handles