Ongoing refactoring, replacing the method to obtain last insert ids.