Fixes to gateway rulefile management