The install/remove manifest logic in main is currently duplicated. This
bloats up main and creates unnecessarily large indented logic. The only
thing that is different between the two large if blocks is a single
function call.
Refactoring to test for which function to call at the latest possible
stage reduces code duplication.