Improve button code

Preliminary work, for peterbe's eyes only