Re-factoring and cleaning code, so it passes under 'pylint'