added cancel services, refactor common functions, bug fixes