Fix bug with caching in flatten-executable.
Refactoring and renaming of methods.