updated fit method, and other bugfixes