Rewrite Javascript base

Clean it up.