Small SCA related fixes v2

Type of fixes:
- use empty() instead of size()
- reduce scope of some variables

----
v2: dropped mapper.c patch as requested in pull request #269