This patch splits the implementation of init into several headers to make the implementation easier to digest and to maintain.