miqButtons fixes

Fix several bugs in the `miqButtons` logic to actually fix behavior of Optimize -> Planing and most likely more places that where broken.

@h-kataria : please, be so kind and review this.
ping @bmclaughlin, @AparnaKarve, @skateman : touching your changes so, please, take a look