Added setRange function and minor changes