Reduce nesting, fixes #5