refactored js. more namespacing.
minor changes.