Fixes scoping issues