updated to CA API v7, cleaned up some of the code