Fixed a bug in replacing emoticons. Added more comments.