Made entity code more functionally idiomatic.