Cleanup: refactoring + remove unused parts.