Cleaned up profile handling code.