incorpporate several changes and bugfixes