Restructure and splitting into several files