small js refactorings, inspired by maintainable javascript talk

http://www.youtube.com/watch?v=c-kav7Tf834