major code improvements