Merge "More fixes towards the race conditions in AMS"