several fixes and additional functions