Autotune code, not finalized yet...