added some tests, cleaned up some unused functions.