More complete corrections code. Large cleanup in a few areas