After hours of work, finally fixed the most ugly bug ever... too ugly to explain. Sets the compiler warning levels higher again. Why were they even low?