Added David Rock's modifications to handle pipe codes.