done some optimisations, more to come hopefully.