remove code within DEBUG2
replace strerror_local by strerror_r
add more cleanups and code simplifications