Fix bugs made in previous commit