some fixes. thanks to @asquared for these