Some bugfixes, design improvements