Fix/commonjs

Implementing @spion's recommended changes