bugfixing and improvements