Refactorings and several minor bug fixes

Hi!

I thought it would be a good idea to bring codebases of iCME and iCME++ closer. I didn't include anything related to my extension, only general bug fixes and refactorings that I've made while writing it. I hope you'll find it good enough for merge.

Five first commits are about general js code conventions, monk-time@cc60795f2d200491e7fb61791e67ae932088a2ab monk-time@7b62ba49b818b7c2053605af038c8e3aa4f700f8 monk-time@30c47e92cd5448bcfdf7c3cd0b53e42facce73a9 monk-time@019b940ae9e85fee379325777f542295ea9a8812 monk-time@dd3e46cca62e554af5b73cd01b278661d53782ca are minor bug fixes, the rest mainly replaces bulky sortings with .sort() and $.grep(). In total this fork noticeably reduces the size of the script:
2431 lines (2029 sloc) 184.581 kb - before
1895 lines (1555 sloc) 166.577 kb - after