fix scope problems in lib