Change cases when exceptions are thrown to not throw

Change some cases where exceptions are thrown to return empty string
Change string at() method to []
Fix warning about signed/unsigned comparison
Add a result check after setting a template
Add const to unmodified variable
Add parents to nodes and check Elif/Else parent types

Add parents to nodes and check that Elif/Else blocks are preceded
by proper If/Elif blocks.