I know you gonna hate me. Can you remove all the code related to smartfolders in this PR? That would makes it much more atomic and will reduce by a big amount the changes of this PR.