Fixes #6587 and #6590
Fixes #6597
Fixes #6591
Merge pull request #6598 from GinjaNinja32/pai

Fixes #6587, #6590, #6597, #6591