Cleaned up, added example and tests