enclose work in functions
remove debugging lines
break work functions out of import handler
remove else after tail call; get more PEP8-compliant
move dangling call out of the way
reverse sense of test
remember to explicitly call return, python-style
remove else after tail call
make if-tree more regular
generalise form selection