Initial support for a managed stack/scratchpad. Still needs some work.