updated for session handling & other improvements