Merge Ros' bug fixes with Stephen's latest changes.