McCarthy finally elected speaker