Improvements and new features.

Improvements and new features by @wyllyan.