Fixes and optimizations aplenty.