various bug fixes, docs update