fixed some js errors, namespaces & coding style