Major rewrite, made library utf-8 safe and added option for global object prefix.