Fixed bugs, added debounce