lots of renaming and changes from dust templates to swig for better IMO syntax. Also improved error handling.