divide main file into client scripts
Merge branch 'organize-code'