Refactor wellsmanager

Put the separate sections into separate functions