Some bugs corrected - 20 runs, no segfault, looks ok