some cleaning and prevention of errors