small fix & optimizations