Optimized sieving and added comments