Fixed compile error and crash from file io