Fixes to refactored code