cleanup, add checks to arguments and responses, add log statements