Major rewrite, now using MySQL
closed a statement