Script and Module Usage

Make this usable as script and as module (sync function).