Subs for buttons

Buttons now call subs that carry out tasks instead of carrying them out
directly. This allows these functions to be called upon without having
to simulate a button click.