A lot of changes to the internal structure to enable it as a module