code changes/fixes for protolus-templates