Add optimize option
Fix warnings