Misc bug fixes and new features. (minor)