Amti refactor

Refactor the low hanging fruit in AMTI. There is enough going on in this function that I think it might make sense to make an `amti.py` module by itself.