Fixed most errors that resulted from removing irrelevant code