File monitor. Huge code cleanup.