Add "failsafe" memory allocation, remove session handling and layouts

We need to cut the functionality down to a sane minimum, refactor, then
start adding back stuff.