removed dead code, left global namespace, separated out javascript