Fix casting bug, add control for hard quotas.
am: bdd4de8a98

Change-Id: Ia3684d4318d1a8b168299d499823fc7d1769614b