compatible with CB1.5.2-R0.2

And small refactoring. this change may cause bugs.