various fixes, cleanup