Code cleanup/optimizations