various changes to fitting functions and addition of clustering script
bug fix when raising an error
changed some plotting routines trivially