Initial implementation of iterative axis alignment

This PR addresses #237. Waiting for feedback from @tomago.