Moving some code around to make this easier to understand
Trying LTO again.  no luck.  will try to compiler newer toolchain later which should fix this bug.