bugfixing and cosmetic changes