refactored class structure and permalink flush