Improved some engine-internal code.