from opengm master to my fork