Implemented rest of clearMemory and removed a lot of comments and console.logs