Add static generator

Close #163
I'm not sure what this code is doing... could you help explain it?