Rewrote most of the core class.