added support for SP flow and enhanced logging