Proper closure scope, fixes #458