Improvements in Peter's flow scripts