Reorganizing pattern/format code