Fixed javascript errors from undefined variables.