Fixes for a few bugs involving AlgorithmBuilder

See commits messages for details.