integrated a lot of fixes