many important fixes