Fixes to github issues on refactoring