More functionality and tests and some pointer cleanup