Generating physical files

It works, but I need to do more testing. I have created the pull request so you can have a look.
Feel free to change the names of classe/methods/variables/parameters in order to  make them clearer.