small changes and optimisations