various edits/optimizations