fixed handling of entity parameters of type string (enumeration items, or simple strings), plus many refactorings.