Fixes to align closer with the undocumented behaviour of the official SDK.