Correct Python error, general refactoring

Refs #10368