memory refactorization and wchar