Massive refactor of the masthead buttons system. Progress commit.