Fixes #7; support graceful cleanup in OOM situation.