fixed calcResiduals, new layout, deleted old files