Fix several bugs caused by previous commit

Oops, my bad ;)