Polished refactor bugs and enhancements