Added changes from @mvallerie as well as some other updates.