Removed unused vars, define undefined ones
added some PHPDocs media.php