Fixed bugs in elif/else ; refactored pre-processing