more of Avar's fixes \o/