implemented #3, plus small fixes