mostly bug fixes and some extensions of existing functions