Various optimisations, unused import cleanups, etc