Avoid some TypeErrors in strict mode

Change-Id: I8ebe7d486c2b43d8c96ce58116e5c38cf769fa79
Merge "Avoid some TypeErrors in strict mode"