bug fixes and flow improvements