Removed unused 'isa' comparisons of an instances.
Fix selection of user entities when they are merged.
Improved API errors handler.