Several media management improvements

upload function still broken