added optimizations for compiling (thanks to @franciscofranco)