Fixed bug in pulse profile. First working version.