fixed unbound variables in xWrite, documented several functions.