path cleanup and some sql added