Fixed conditional declaration of functions; passed in window elm to aid in minification.