(#2437) Use interpolation instead of string concatenation

Following a comment on pull request #1924
(#2437) Convert case statement on boolean to if/else (1/2)

For the @invar boolean variable, following comment on pull
request #1924
(#2437) Convert case statement on boolean to if/else (2/2)

For the @inobject boolean variable, following comment on pull
request #1924. Also removed some dead code and fixed comments.
(#2437) Split logic into methods to lower complexity

The case statement is pretty deep and hard to follow.
Also corrected 2 other occurrences of string concatenation.
(#2437) Split logic into methods to lower complexity (continued)

Also renamed internal state variables to be more explicit