Fix implementation to better align with original.