synced from upstream master

some changes will need to be readded