Applying several fixes

- Flushing caches
- Release connections
- Step reorganization
- Tested on Postgres and JavaDB