Replace direct calling to struct members with functions for future multi-pug session support.
Fixed IRC loop bug.