Completely rewritten.