New library functions and bug fix