Fixed two issues with how the app handles brackets

- unable to close a multiple set of brackets in a row (issue #31)
- fixed a critical issue (discovered while fixing the other bug) that
would cause brackets within the appstate to not be saved properly
because incrementing happend after the app saved its state