Also, why use instance vars inside the module? Not a blocker, but may be worth refactoring some of this into a helper class.