Rewrite how stack frames are allocated.
Fix some local bugs.