Refactoring stage 1, add more generic gsf writer function