Fix a few long standing bugs.