several fixes, not yet working as expected