Added adopt() and fixed a minor bug