Changed generic exception to specific

Replaced Exception with InvalidOperationException when adding a macro to
the repository.
Renamed callbacks and added minimize/maximize code