Change head/tail to pattern guards.