enhanced code for some entity types (removed unused variables, added explanations, made some decomposition in the hint bubble)