Fixed js problems highlighted by Resharper