Added some optimization stuff