Fixed some scoping issues.