ported over changes for bugfix 59