Implement a memory for the controller (accesible via mem.) and cleanup code
Based on PilzAdam's code.