fix a few errors/crashes