various fixes and additional bugs