merged and some cleaning