Some more refactorings (Please revert if it fails)