Clean up, refactoring, some fixes.