Minor code changes + style following review
Fixes #4135 kuddos @halfdan for finding the bug & patch!