Adding Error Handeling and maxfile configuration

@jbest84 Please Review