Initial SQL generating code
Clean shutdown and startup error handling