Several bug fixes and implementions.