Attempt at further optimizing the library.

Attempt at further optimizing the library.

# Added a local reference to the math.random library -> Reduce scope traversal
http://codeutopia.net/blog/2009/04/30/optimizing-javascript-for-extreme-performance-and-low-memory-consumption/

# Change for...in loops to Object.Keys
http://jsperf.com/object-keys-foreach-vs-for-in-v2/2

# Reduced unnecessary local variables and references

# Formatting