Refactored ObjectUtils. Fixes #567