Updates to enable processing media tags.

Updated the source to enable the processing of Media tags by wrapping
the process function in a recursive method which detects if the rule is
a media tag then processes all child rules.
Modified the code to be more functional.
Updated formatting.