Updated with Friends code and fixed CR/LF's. Patched against latest code...

... as I couldn't squash properly on my branch

You will need to check if I screw up versions etc... but it's the best I've been able to do so far. Unless you can tell me how to create a fork at a specific hash?