Added support for the #replace tag, which globally replaces a piece of text with another, cleaned up some code more to my liking.