fixed scoping issues in backend
Fix small scoping / naming issues