Updated creation of Executor to be used when needed

Updated the executor so that it will be used when it is needed and
destructed after.
Merge pull request #2 from fasalex/master

fixed #1