fixing various things (mainly related to commmonjs misunderstandings) --...

... see comments

Seems like you are a bit confused about how commonJS `require` is supposed to work as I saw no `exports` or `module.exports` anywhere.

These fixes should help you get on the right track.
Please merge ASAP so I can delete my fork.