make lastState always equal to this and some code cleanup/getting rid of unused code