Refactor code

- Remove unnecessary (unused) AMD and global module patterns.
- Splits functionality into several files.
- Improve example and test.