Fix all bugs introduced in the current PR