Add some misc functions and move the optiz3 part.