library functions. minor bug fixes