Refactored all sources to support requirejs module system. Also updated demo page