forked from: forked from: Smoking Cursor G2

added basic optimizations, the rest is up to logic improvements