Fixed issue with media spawning more than one file

Optimized speed, and fixed issue with media spawning more than one file