asan, ubsan, valgrinds issues fixed