Fixed a few crash bugs that appear with full optimizations enabled