Fixes and some optimisation.