Refactor and updated Smarty