Missed a debug var
More refactoring
Cleaning up some code
Merge