Updated library to use generators and decorators to make this easier to use in other projects.