Added a number of changes to support dynamic unit creation