Lazy task creation + overall cleanup of pipeline implementation

Similar to #920.