Wrapped in an IIFE to avoid global polution, added to window as window.Instance
Moved var declarations to top of functions, avoids hoisting issues'
Made the indentation consistent
Added JSdoc block for each function