multisession and global api refactoring