Fix remove playlist bug and code refactoring