Refactor the warnings code

Provide methods to add and remove warnings more easily.

Change-Id: Ia26cfce5de950bde311e0123b7c23c5645914d68