Fixed a NullPointerException (a null bean name) in case the custom task has a task via its class attribute. Extracted part of the logic and added comments for readability.