cleaning up some code, wrapping js with namespaces/closures