made to_hash properly encode sub models