Almost done bugfixing