Factored out all of the button creation into a generic function.