REFACTOR More code consolidation and cleanup