Patch a bunch of bugs for pencilcode compat