Rewrote media module from scratch