Rewrites some parts of the code. Needs to be tested. FASTEST MODE 2 seems to be buggy.