Made changes to speed up code execution.