Renamed clear function, fixed up memory leak