Removed some bugs phi and nan  mostly