Small fixes in wrap method - use "\r" instead of "\n".
Adding logging to some places.