First pass at being right
Added reset handling.