fix many a bug, use double-precision norms