First pass at working cleanup code (no longer leaks if reset is called).