Restructured code, added timestamps in messages