Refactoring + fixes.
Fixed most regressions. Concurrent transactions still broken.