more optimizations, better cleanup less clutter

more optimizations, better cleanup less clutter