kwds is uninitialized here, probably the cause of the segfault