Updated to newer Python syntax where possible