debouncing on the code

If you can, avoid them! if you can't, be sure to have at least a lower value pull up (start with 1k) and apply filtering. This can be in hardware or software.

In hardware something like

                      VCC
                       ┬
                       │
       long wire       1k
 ┌─────────────────────┴───100k───┬───Input
 │                                │
 │                              100nF
  \                               │
 │                                │
 ┴                                ┴
GND                              GND

would be pretty efficient I think. Also adds protection to the inputs.