optimizations / fixes