Refactor views and scripts