Adding debounce code, beginnings of main loop