Small changes and optimizations