Fixed minor database bugs