Change castFromString so it can cast to constant string references

Before this change, constant string references were initialized from temporary stack allocated strings, which resulted in memory bugs.
Merge pull request #47 from krisr/develop

Change castFromString so it can cast to constant string references