fixes some bugs introduced in 6ec949693e91e8fe135cd366f3b761868363b456