Modified createprofile class, fixed some bugs