Small fixes in writer and generator