minor fixes & optimizations
attempt at optimizing