Fixed database locked issue

Liberal use of disconnect and finish.

Updated DEPLOY, removed some lines.