Sets in relatedto not handled
Some refactoring