Refoactor structures of js and use requirejs patterns.