Declare some used variables using defvar

This prevents compile warnings about free variables.