Update 2.5

Combine Andrew's code with my new code updates.
Changed substr() to replace()
Merge pull request #505 from dayst/master

Update 2.5