added reset function, other minor tweaks