Small SCA related fixes

Type of fixes:
- use empty() instead of size()
- reduce scope of some variables