Some bugfixes, only partly functional