Better support for auto-boxing/unboxing

I have ran into some trouble while mixing primitive types and their wrapper classes in entities. This commit addresses that issue.