compute: traversal updates scope after optimize calls
compute: clean up try-except and if-else blocks
Merge pull request #839 from mrocklin/optimize-and-scope

compute: traversal updates scope after optimize calls