numerous bug fixes related to restructuring