many bug fixes