Fix reference to undefined variables in some cases (use isset)