Merged in Scott's changes manually