some optimisations to get around unnecessary db-calls.