Fixed and improved provider registration. Removed duplicate code.