Refactor profile handling.

- Mostly try to extract error handling into separate functions.
Copy the default config file to all profiles' dir upon profile's creation.