Refactor code, zendify it and add comments.