wrote autofit API, tidied code
finished autofit api and added to optima.py