This solves the problem that the first few lines are logged twice on matrix.org. Hopefully the comments explain it.