Cleanup and adds teardown function