Refactored task registration.