Commenting and Refactoring

Some conditionals were put into separate methods for cleaner code. Added comments added for further comprehension.