many bug fixes all around