Additional code generation update

Add variable definitions to code generation
Add a number of string functions
Fix various bugs