cleanup and autoranging