Ignore leading and trailing white space, spotted by mispp
Prepare API for profiles support
Some simplifications and renaming