added auto-reset, and some other small stuff.