Restructure code into commonjs modules

we quality code now