Checked in old version from MSc thesis
Updated version from MSc thesis.