Fixed startup assertions
Added try/finally clauses