There's a start tutorial for using XML in the ribbon on our page. Look at the last sample and simply remove size="large" in each line leaving just a space which will give you small buttons stacked in threes.

Really, you are just making work for yourself using Steve's very old legacy code which is from a version over 10 years old.