corrected and commented some changes from sebastian