Small implementation changes to debounce. Only increments counter while running flag high.