Use cream.log to log api messages
Move some code around