Bugfix variable scope problems.