Bug fixes on db loading