Made some code improvements