Some performance optimisations have been made.