misc code improvements