Some fixes, file type checking