better cleanup, less crashing

addresses #160