Refactoring the controllers of flash_pvt