fixes, tweaks, and optimizations