refactor a bit of the native extension as3