Cleanup & remove code duplication.