Improved Discovery performance

Layout still needs some last touches, and I think there might be a logic
error (line 118, I put a TODO)