Move profile handling to new api class and refactor related activities

Change the syntax for SAN in the profiles and fix building profiles.
All profile related methods are now in the API::Profile class.