Some attempts at bugfixing