Rewrite nearly complete
Refactored module to use new code