Fixes reflection: take into account base classes
More cases are handled
More cases are handled