Refactor and make static pages friendly