Some minor fixes and preliminary  testing code.