Fix #1040
Updated tests
Optimizations
Interned strings
Make tests pass
Test case for #1275

(cherry picked from commit b617bab7ee767a3cbeea978d769fb842c7ef9834)
Fix #1275

(cherry picked from commit d40c88a96fc60553b5e428e60a5bff5364127f1a)
Fix controller length for #1275