Fixed many small CPU bugs, and memory bugs