Refactor

Bringing this Python port into line with @jasonlong's recent changes: 

- jasonlong/geo_pattern#16