Some changes suggested by Eclipse PyDeV code analysis

@RayPlante Let me know if some of them are incorrect and I'll revert.