Improved HTML entity replacement and changed an int to NSInteger