Add external object to init-function

Add "ext" parameter - external object. For default - window
Rewrite log-function
Big updates