bunch of cleaning and some fixes