A better structure. Also added normalize