$db->Execute($sql);
    $sql = 'SELECT * FROM ' . $tbl;
    $rs = $db->Execute($sql);
    outputnow('Cleaning ' . $tbl . ' table... ', false);
    outputnow($rs->RecordCount > 0 ? 'Failed' : 'OK');
}
$filename = $_GET['f'];
$filepath = GEDCOM_DIR . $filename;
//$maxtime = ini_get('max_execution_time') - 5;
$maxtime = 30;
$stime = time();
# initialize gedcom parser
outputnow('Initializing gedcom parser...');
require_once CORE_PATH . 'gedcom.class.php';
$gedcom = new GedcomParser();
$gedcom->Open($filepath);
# Set the file offset and set the factkey if needed
if (isset($_GET['offset']) and $_GET['offset'] > 0) {
    $offset = $_GET['offset'];
    # we need to set the factkey to the highest already in the database
    # in case we are not starting from the beginning of the file
    $sql = 'SELECT factkey FROM ' . TBL_FACT;
    $rs = $db->Execute($sql);
    $factkey = 0;
    while ($row = $rs->FetchRow()) {
        if ($row['factkey'] > $factkey) {
            $factkey = $row['factkey'];
        }
    }
    $gedcom->factkey = $factkey;
} else {