Added memory clearing.