Adding sessions, fixed a bug and adding try/catch to prevent crashes.