scope: bug fixes
const correctness