Added media tag support. Refactored a bunch of stuff.