Switched to functions possibly using scope (documentation and tests are currently all screwed up)