Improve VM trap entry code