fix a critical point error; plus some style fixes