fix crashs, bugs