Fixed bugs, works with CMOS now.