general code improvements