More robust lease handling code