If an alignment store is provided, there's no need to lock the function. Moved the accumulation of the transforms into a dedicated method to save lines of code. Added few asserts to ensure that the transforms are actually valid
Tagging: @boudreau, @tsulaia