Fixed some bugs with database module.