Reformat the source code to make the formatting more consistent

The new formatting was done through http://jsbeautifier.org/ with an additional few manual tweaks to take care of long lines.