Refactored for greater speed and simplicity and reduced memory usage - internal classes now favor prototype functions over closures.