Added some optimization rountines (but they don't work yet ...at least for me!)