Refactorings and error handling

Looks like previous pull request was not merged. It also contains it (add folder to playlist and some other stuff)