Move models code to lib so that it's always loaded before other scripts.
Move function definitions in subscribe.js to top before they are used.