Added a utils JS file and performed some minor refactoring.
Changes some =='s to ==='s and removes some dead code.