Tables and procedures updated

The code does not drop, create or use any database anymore. Some
inconsistencies in the tables and procedures were fixed.