Refactor most of ah_bootstrap.py into a class

I think this will make it easier to update it in the future and to understand what's going on.