Refactor (and improve) playlist handling.