Close memory leak. fixes #48.