Reorganized code, added swap check type