Updated with some comments from Stefcho. More comments to be incorporated soon.