Fixed roam bug of replacing file contents. Optimization.