Improved library performance. Fixed minor bug.