api docs and a few minor bug fixes