Some debugging and mem optimization.