cleaning up memory after state