Some minor changes focused on plugins

Although I've been quite busy lately, I thought the project needed a *keep alive*, based on some comments in the forum. I've been mostly changing plugin-related stuff.

Please, review the SQL change carefully. I don't really know why there was a join on a derived table so probably I'm missing something.