encoder interpretation and general debouncing added