Refactored algorithm code

Removed use of parallel lists and Hungarian notation
Compacted code
PEP8 + pylint compliance