bugfixes and derivative based phi