Clear existing whitelists if installing new app
Fixed applying template in relation to default restrictions

Fixes #1566