adds AMD and CommonJS export support [update]

Just made it more module friendly and also fine tuned the validation method.