renamed buttons defines, reorganized a bit of code