Fix php errors.
Add content index block and refactor some code.