attempting small optimizations, though it's broken now.