fix bug in fitting, improve docs