Cleanup

General library code and test cleanup