Error checking for duplicate filenames on uploads, random number appending. Minor style fixes.