Removed duplicated code
Javascript fixes + workaround for old internet explorer < 9