Cleanup: minor optimisations, formatting.