Fix various bugs and test problems.