Smarty extension fixes

This fixes issue #295, as well as some other minor issue.