medialibrary code cleanup