Various small changes + compiler optimalizations