Refactoring the code

added some namespaces. split the files into several folders