some (not all) bugs fixed