many various fixes and new functions