Major refactor to support performance improvements, better design, and new API