Add optional endcode argument to stopPrint; minor fixes/improvements.