Fix various errors and warnings from pylint