Update smarty and fix some bugs