Some minor consistency fixes. TODO: reject programs that require non-existing stack elements during type checking.