Fixed variable scope issues in libraries.