More clean up, added tests