Random changes

Some small changes in the code to work better with documentRepair
implementation. A bunch of cleanup needs to be done but everything looks
functional. Will test shortly.