roundoff bugs corrected