Fixing some edge cases in Entity::set()