changed to be compatible with unity3d log handler friendly.
cleaned up code.