Fixed Issue #240: SQl fix and routing in finalize