Completely creates the buttons dynamically now. I've also cleaned uop the code a bit and added some documentation.