Fix some issues in the entity and subscript code