numerous bug fixes, see issue tracker