Improved and commented on in f4a75f0106f6ebea6707a48cc95d8f420c7f15d1