Refactoring

Hi,

I think my refactoring is complete, however I didn't test the "following" option because it's not really clear to me how does it work. Could you give me some feedback?

Also @jtomaszewski, could you test if this is easily extensible and if you're able to adapt your compass plugin to work with it ?

Cheers,
Marek
can you pull this into a separate function?