added some new functions to library and fixed an embarassing number of typos