Added max length functionality
Fixed valueof error