Fixed few bugs with empty DB.