Fix bugs with on-page exception of variables not being defined