Updated some code so that it can be optimised by closure compiler