Adds cleanup() function
Closes #47