few fixes, still a segv somewhere
fix segv