Improve Smarty support.
Seperate Smarty2 and Smarty3 code.