fix errors and update docs to match code more closely