Fixed to_database() method.