numerous fixes and minor additions