Moved class extension code earlier