Numerous bugs fixed.