Fix scoping, add standard logic.