Add freeze button and cleanup code