various import and SQL fixes