Added references
Changed stuff according to Graham's suggestions