Added more protection for invalid parameters to the database handling methods.