Tweak class resolution logic to rely more on given classnames (which gives better results on midgard-portable,
and should not change the semantics when running with the extenstion loaded)