Fixed crash on profiles having / in their names. Fix #36
Refactor a bit.
Fix deleting profile if it is empty.