Refactor to improve perfomance, mainly in computing canonical basis. Add faster *get_aibasis* method to *Context*.