Centralize more task-initialization code.

#590