Some bits refactored