moving in some general purpose routines from watchque-hs