fixed norm factor, added inverse, random cleanup