Tiny optimisations to database loading
Other small fixes