My cleanning ups of Phil's implementation