Change code so that we correctly send headers to clients