Fixed segfaults on p3
Fixed p2