minor changes and optimizations