added a destroy function and cleaned some things up