Output writing done, minor fixes.