plug environment and refactor front controllers