Fixed some copy-and-paste errors and moved a file check