Correctness and performance.

Fix the implementation of ToInteger; use String#substr for performance.