[FIXED JENKINS-20522] Proper usage of TopLevelItemDescriptor

Fixes [JENKINS-20522](https://issues.jenkins-ci.org/browse/JENKINS-20522) and related issues needed for use with the CloudBees Templates plugin and perhaps others. Most crucially, avoids using `Descriptor.clazz`, which does not work with dynamic descriptors.