Refactored maintenance scripts