Fixed javascript errors