fixed some segfault, added more try/catch