y scale fix, some code improvements