Implemented session handling and added polling