fix bugs and warnings from compiler warnings (memset parameter order, shadow, ...)