More robust Resource/Element/Class detection

Still does not create valid Swift classes; no efforts yet on the Python side.