Added some performance optiminations