minor optimizations and cleanings