Added some util functions. Some work on pi.session