reorganize file structure, fix substitutions factory