Attempt at optimizations