some bug cleanup and import fixes