improved writeouts and printouts for k