copy from git://gpsmid.git.sourceforge.net/gitroot/gpsmid/GpsMid for study