several bug fixes and doc improvements