Use the cleanup stack correctly

If the cleanup stack is used correctly, there should be no memory leaks in the code - which in itself guarantees that the application is not using more RAM than it needs to.