Various optimizations. Added commenting. Added a new method on NSRegularExpression for convenient string replacing.