Refactor to use vector instead of native array

Thanks to the magic of template (and macro), there is little performance
loss in runtime. It makes the modules easier to use. At the meantime, we
can benefit from enabling _GLIBCXX_DEBUG when testing.