clone from http://sourceforge.net/projects/safmq