Some cleanups and modifications. the k's are now floats.