Refactored prepareClassForBindingIfNeeded.