Fixes on relay and tofilename