Lots of refactoring. Using module pattern now.