misc function additions and improvements