remove any types and improve callback inference