Complete rewrite of Restrictions API

This removes a ton of duplicated code and allows for much
easier implementation of new restrictions.