Fix some minor bugs, and Python 3 compatibility
One style change `x if x else default` changed to `x or default` which is more idiomatic