merged bugfixes from http://sourceforge.net/projects/openemm/files/OpenEMM%20software/OpenEMM%206.0/Bugfixes/