updated to support debug flag, reintroduce persistent sessions, different logging