Optimisations giving some speed up, and fixed a bug causing random
crashes of rtbver.