minor optimizations and changes