Added some basic optimizations