Various smallish JIT optimizations

See the individual commits for details. Please don't push this quite yet; I haven't done much testing.