minor improvements and optimisations