improved performance and tidy-up