Be more cautious when storing and restoring button states.

This fixes #54.
Signed-off-by: Jean-Yves Tinevez <jean-yves.tinevez@pasteur.fr>