Code reorg and ensure Task registry is defined only once