I've fixed various issues after a careful verification with vagrind that I ignored before (always listen to valgrind...). Maybe it will fix crash & lock problems