Updated to use require js for dependency handling. Should do some more refactoring around this