[0.3] Fix random CS issues found by Scrutinizer-CI
Merge pull request #587 from stloyd/bugfix/cs_fix

[0.3] Fix random CS issues found by Scrutinizer-CI