Merged in some of Riad's changes.