More work on fixing subtle bugs