fix some conflicts and a few issues leading to segmentation fault