Module pattern version of the Javascript is now working. Should be done. Needs to be tested and cleaned up.