Fix problems with empty databases