Re-structured for ease of unit testing and fixed pykka property access bug (issue #3).