Fixed bug where database was not being populated sometimes.