Updated writing config; Moved most of the file to using `after' macro.