Better type conversion for sending objects to the database