Merging Max's changes.