Reorganise code and test trivial pattern delay.