Added optimization
Fixed some stuff