Minor fixes: some more code needed to make it work.