Work

merge my work with your latest fixes. there's a lot of cosmetics like type-fixes and error-checks, but also 2 new functions (5374 and 5376) plus some other things.