Refactor profile handling.

- Make calling the profiles module easier and more straightforward.
- Clean up exception handling.