cleanups and small fixes as suggested in review comments