Removed some useless code, split up code to external JS files for ease
of coding.