Standardize error messages and return codes

Return code reference:
 * 1 - general error
 * 2 - input error
 * 3 - file error