Took care of warnings from pylint

Removed unneeded imports
Use an explicit loop instead of the reduce function