When I see this code and related to quite stupid reset in Messages I think you should consider make header accepting block, so you can write 
```
message = sprintf ...
Messages.header(message) do
  yield modules[i]
end
```
this code should ensure that after finish, it is reset