Optimised some core functions.