minor changes and optimisations