Performance Optimizations / Code cleanup

https://dl.dropboxusercontent.com/u/763272/tmp/Screenshot%20%2819%29.png
I cleaned up the code and increased the performance from 135ms for 100,000 cycles to 50ms on a beefier computer.