fixes issue 1985

plus made a pass to jsbeautifier for improved reading
plus fixed an annoying trailing comma that could cause issues with IE >= 8
Merge pull request #510 from niphlod/fix/1985

fixes issue 1985