partial fix (nothing done about media directories); original patch by Doug Blank, then modified by me svn: r18845