Massive refactoring and added early version of filesplitter