some performance optimisation and tests