Fixed a bug causing chained multiplication of constants to be ignored.
Fixed a bug causing chained multiplication of constants to be ignored.

Changes to replaceAll that replaced the previous looping structure with
use of the "g" regex flag caused replaceAll calls that need to use the
same part of a string multiple times to crash. I have reverted replaceAll
to using loops, which fixed the issues.

JGelfand/PersonalProjects,JGelfand/PersonalProjects