Optimisation broke the solution, fixed it
Slight Python tidy up