Stability fixes

Local variables are accessed correctly now, and function parameters are
taken off the stack before returning.