Fixed more bugs in doLineClear, began some refactoring of doLineClear