Optimize code after remnants of other experiments