Clean version with message logging

Cleaned up code, added coments. Listener is called from login and works
with the stored messages on Openfire server.