More code cleanup and updates to the sample.

Fixed some DB locking issues around large selects & drop statements.