Moved clean up to a separate file