Restructured, minor improvements

Have restructured code, renamed variables and functions, made some
minor code improvements
Merge pull request #36 from jehope/msnJSMods12Dec2013-2

Restructured, minor improvements