Shifting reference code to LocalContribWithReference class

And added some documentation for the new functions