fixed ordering problems that caused exceptions when creating objects from database