Mega refactor