[0.6.188] refactoring the resource managing code