rework & tiny optimizations