incorporate several changes and bugfixes