buncha optimizations