Preparing for mysql

Major refactoring.
Prepared data and execution strcuture.