Optimizing some stuff