Fix problem extracting last table of database file. Functions refactorized.