added merge and some cleanup