some more cleaning and optimizations