fix bugs in library